package com.cyj.dream.admin.persistence.manager.systems;

import com.cyj.dream.admin.model.system.SysPermission;
import com.cyj.dream.admin.persistence.service.ITbSysPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description: 系统权限管理器
 * @BelongsProject: dream-DreamChardonnay
 * @BelongsPackage: com.dream.DreamChardonnay.persistence.manager.systems
 * @Author: ChenYongJia
 * @CreateTime: 2021-05-18 11:23
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Slf4j
@Component
public class SysPermissionManager {

    @Autowired
    private ITbSysPermissionService iTbSysPermissionService;

    /**
     * 查询当前系统所有权限信息
     *
     * @return java.util.List<com.dream.DreamChardonnay.model.system.SysPermission>
     * @date 2021-5-18 11:28:52
     * @author ChenYongJia
     * @version 1.0
     */
    public List<SysPermission> queryAll() {
        log.info("进入 SysPermissionManager 查询当前系统所有权限信息方法......");
        return iTbSysPermissionService.list();
    }

    /**
     * 批量插入权限数据
     *
     * @param pList 系统权限集合
     * @return boolean
     * @date 2021/5/18 11:39
     * @author ChenYongJia
     * @version 1.0
     */
    public boolean batchInsert(List<SysPermission> pList) {
        log.info("进入 SysPermissionManager 查询当前系统所有权限信息方法......");
        pList.stream().forEach(item->{
            item.setCreateTime(LocalDateTime.now());
            item.setCreateUserId((long) 1);
        });
        return iTbSysPermissionService.saveBatch(pList);
    }

}
